/**
 * Title: SearchListAdapter.java
 * Description:
 * Copyright: Copyright (c) 2008
 * Company:深圳彩讯科技有限公司
 * Author 罗旭东 (hi@luoxudong.com)
 * Date 2013-12-12 下午2:01:13
 * Version 1.0
 */
package com.luoxudong.phonenumber.ui.adapters;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.luoxudong.phonenumber.R;
import com.luoxudong.phonenumber.logic.search.vo.SearchItem;

/** 
 * ClassName: SearchListAdapter
 * Description:TODO(这里用一句话描述这个类的作用)
 * Create by 罗旭东
 * Date 2013-12-12 下午2:01:13
 */
public class SearchListAdapter extends AbsBaseAdapter<SearchItem>{
	public SearchListAdapter(Context context, List<SearchItem> list) {
		super(context, list);
	}

	@Override
	protected View getItemView(int position, View convertView, ViewGroup parent) {
		ViewHolder viewHolder = null;
		
		if (convertView == null)
		{
			convertView = inflater.inflate(R.layout.search_item_layout, null);
			
			viewHolder = new ViewHolder();
			viewHolder.searchNameTextView = (TextView)convertView.findViewById(R.id.tv_search_name);
			viewHolder.selectedValueTextView = (TextView)convertView.findViewById(R.id.tv_selected_value);
			viewHolder.searchMoreImageView = (ImageView)convertView.findViewById(R.id.iv_search_more);
			convertView.setTag(viewHolder);
		}
		else 
		{
			viewHolder = (ViewHolder)convertView.getTag();
		}
		
		SearchItem searchItem = getItem(position);
		String selectedValue = context.getResources().getString(R.string.nolimit);
		viewHolder.searchNameTextView.setText(searchItem.getSearchName());
		if (searchItem.getSelectedValue() != null)
		{
			selectedValue = searchItem.getSelectedValue();
			
		}
		viewHolder.selectedValueTextView.setText(selectedValue);
		return convertView;
	}
	
	class ViewHolder
	{
		public TextView searchNameTextView = null;
		public TextView selectedValueTextView = null;
		public ImageView searchMoreImageView = null;
		
	}
	
}
